# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import django.utils.timezone
import django.core.validators
from django.conf import settings
import django.contrib.auth.models


class Migration(migrations.Migration):

    dependencies = [
        ('auth', '0006_require_contenttypes_0002'),
    ]

    operations = [
        migrations.CreateModel(
            name='MyUser',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('password', models.CharField(verbose_name='password', max_length=128)),
                ('last_login', models.DateTimeField(verbose_name='last login', blank=True, null=True)),
                ('is_superuser', models.BooleanField(verbose_name='superuser status', help_text='Designates that this user has all permissions without explicitly assigning them.', default=False)),
                ('username', models.CharField(verbose_name='username', max_length=30, help_text='Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.', unique=True, validators=[django.core.validators.RegexValidator('^[\\w.@+-]+$', 'Enter a valid username. This value may contain only letters, numbers and @/./+/-/_ characters.', 'invalid')], error_messages={'unique': 'A user with that username already exists.'})),
                ('first_name', models.CharField(verbose_name='first name', max_length=30, blank=True)),
                ('last_name', models.CharField(verbose_name='last name', max_length=30, blank=True)),
                ('email', models.EmailField(verbose_name='email address', max_length=254, blank=True)),
                ('is_staff', models.BooleanField(verbose_name='staff status', help_text='Designates whether the user can log into this admin site.', default=False)),
                ('is_active', models.BooleanField(verbose_name='active', help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', default=True)),
                ('date_joined', models.DateTimeField(verbose_name='date joined', default=django.utils.timezone.now)),
                ('NFC_id', models.CharField(max_length=100, null=True)),
                ('ext', models.CharField(verbose_name='分机号', max_length=50, null=True)),
                ('short_number', models.CharField(max_length=50, null=True)),
                ('mobile_phone', models.CharField(max_length=50, null=True)),
                ('head', models.CharField(max_length=500, null=True)),
                ('sign', models.CharField(max_length=500, null=True)),
                ('entry_date', models.DateField(verbose_name='入職日期')),
                ('sex', models.CharField(max_length=10, choices=[(0, '男'), (1, '女')])),
            ],
            options={
                'db_table': 'tb_user',
            },
            managers=[
                ('objects', django.contrib.auth.models.UserManager()),
            ],
        ),
        migrations.CreateModel(
            name='Duty',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('name', models.CharField(max_length=50)),
                ('code', models.CharField(max_length=50, null=True)),
                ('desc', models.CharField(max_length=500, null=True)),
            ],
            options={
                'db_table': 'tb_duty',
            },
        ),
        migrations.CreateModel(
            name='Function',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('code', models.CharField(max_length=50, null=True)),
                ('name', models.CharField(max_length=50, unique=True)),
                ('parent_id', models.IntegerField(null=True)),
                ('parent_code', models.CharField(max_length=500, null=True)),
                ('full_code', models.CharField(max_length=500)),
                ('desc', models.CharField(max_length=500)),
                ('desc2', models.CharField(max_length=500, null=True)),
                ('create_date', models.DateTimeField(auto_now_add=True)),
                ('is_active', models.BooleanField(default=True)),
                ('definer', models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='F_user')),
            ],
            options={
                'db_table': 'tb_function',
            },
        ),
        migrations.CreateModel(
            name='LoginLog',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('login_user', models.CharField(max_length=50)),
                ('login_project', models.CharField(max_length=50)),
                ('login_ip', models.GenericIPAddressField()),
                ('login_date', models.DateTimeField(auto_now_add=True)),
                ('logout_date', models.DateTimeField(auto_now=True, null=True)),
            ],
            options={
                'db_table': 'tb_login_log',
            },
        ),
        migrations.CreateModel(
            name='LoginToken',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('user_id', models.CharField(max_length=10)),
                ('token', models.CharField(max_length=50)),
                ('end_date', models.DateTimeField()),
            ],
            options={
                'db_table': 'tb_user_token',
            },
        ),
        migrations.CreateModel(
            name='Org',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('org_name', models.CharField(max_length=100)),
                ('parent_id', models.IntegerField(null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('create_date', models.DateTimeField(auto_now_add=True)),
                ('org_code', models.CharField(max_length=50)),
                ('cost_code', models.CharField(max_length=50, null=True)),
                ('org_desc', models.CharField(max_length=500, null=True)),
                ('org_desc2', models.CharField(max_length=500, null=True)),
                ('org_people', models.IntegerField(null=True, default=0)),
                ('org_people_all', models.IntegerField(null=True, default=0)),
            ],
            options={
                'db_table': 'tb_org',
            },
        ),
        migrations.CreateModel(
            name='OrgLevel',
            fields=[
                ('level', models.IntegerField(primary_key=True, unique=True, serialize=False)),
                ('level_name', models.CharField(max_length=100)),
                ('level_code', models.CharField(max_length=50)),
                ('id', models.IntegerField(unique=True)),
            ],
            options={
                'db_table': 'tb_org_level',
            },
        ),
        migrations.CreateModel(
            name='OrgRole',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('name', models.CharField(max_length=100)),
                ('code', models.CharField(max_length=50, null=True)),
                ('desc', models.CharField(max_length=500, null=True)),
                ('level', models.IntegerField(unique=True)),
                ('create_date', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'tb_org_role',
            },
        ),
        migrations.CreateModel(
            name='OS',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('OS_name', models.CharField(max_length=50)),
                ('OS_code_name', models.CharField(max_length=50, null=True)),
            ],
            options={
                'db_table': 'tb_OS',
            },
        ),
        migrations.CreateModel(
            name='Project',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('PID', models.IntegerField(unique=True)),
                ('short_name', models.CharField(max_length=100)),
                ('full_name', models.CharField(max_length=500)),
                ('desc', models.CharField(max_length=1000)),
                ('opinion', models.CharField(max_length=500, null=True)),
                ('http_address', models.CharField(max_length=200, null=True)),
                ('server_ip', models.CharField(max_length=100, null=True)),
                ('create_date', models.DateTimeField(auto_now_add=True)),
                ('have_app', models.BooleanField(default=False)),
                ('manager', models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='PM')),
                ('proposer', models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='PP')),
            ],
            options={
                'db_table': 'tb_project',
            },
        ),
        migrations.CreateModel(
            name='PushToken',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('token', models.CharField(max_length=100, unique=True)),
                ('create_date', models.DateTimeField(auto_now_add=True)),
                ('OS', models.ForeignKey(to='ac.OS', related_query_name='PT_query_OS')),
            ],
            options={
                'db_table': 'tb_push_token',
            },
        ),
        migrations.CreateModel(
            name='QRCode',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('uid', models.CharField(max_length=50, unique=True)),
                ('username', models.CharField(max_length=50)),
                ('create_date', models.DateTimeField(auto_now=True)),
            ],
            options={
                'db_table': 'auth_QRcode',
            },
        ),
        migrations.CreateModel(
            name='Role',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('role_name', models.CharField(max_length=100)),
                ('role_code', models.CharField(max_length=50, null=True)),
                ('role_desc', models.CharField(max_length=500, null=True)),
                ('func_list', models.CharField(max_length=500)),
                ('create_date', models.DateTimeField(auto_now_add=True)),
                ('is_active', models.BooleanField(default=True)),
                ('project', models.ForeignKey(related_name='R_project', related_query_name='R_query_project', to='ac.Project')),
            ],
            options={
                'db_table': 'tb_project_role',
            },
        ),
        migrations.CreateModel(
            name='RoleFunctionMap',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('function', models.ForeignKey(related_name='RF_function', related_query_name='RF_query_function', to='ac.Function')),
                ('role', models.ForeignKey(related_name='RF_role', related_query_name='RF_query_role', to='ac.Role')),
            ],
            options={
                'db_table': 'tb_role_function_map',
            },
        ),
        migrations.CreateModel(
            name='Site',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('site_code', models.CharField(max_length=50, unique=True)),
                ('site_name', models.CharField(max_length=50)),
                ('area_code', models.CharField(max_length=10, null=True)),
                ('create_date', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'db_table': 'tb_site',
            },
        ),
        migrations.CreateModel(
            name='Status',
            fields=[
                ('status_code', models.IntegerField(primary_key=True, unique=True, serialize=False)),
                ('status_name', models.CharField(max_length=50)),
                ('status_type', models.CharField(max_length=100, null=True, choices=[('User', '用戶類型'), ('System', '系統類型')])),
                ('status_desc', models.CharField(max_length=500, null=True)),
                ('id', models.IntegerField(unique=True)),
            ],
            options={
                'db_table': 'tb_status',
            },
        ),
        migrations.CreateModel(
            name='UpdateLog',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('update_object', models.CharField(max_length=50)),
                ('update_type', models.CharField(max_length=50)),
                ('update_user', models.CharField(max_length=50)),
                ('update_date', models.DateTimeField(auto_now=True)),
                ('old', models.TextField(max_length=1000)),
                ('new', models.TextField(max_length=1000)),
            ],
            options={
                'db_table': 'tb_update_log',
            },
        ),
        migrations.CreateModel(
            name='UserCheck',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('opinion', models.CharField(max_length=300, null=True)),
                ('update_date', models.DateTimeField(auto_now=True)),
                ('check_user', models.ForeignKey(related_name='UC_check', related_query_name='UC_query_check', to=settings.AUTH_USER_MODEL)),
                ('proposer_user', models.ForeignKey(related_name='UC_proposer', related_query_name='UC_query_proposer', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'tb_user_check',
            },
        ),
        migrations.CreateModel(
            name='UserOrgMap',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('create_date', models.DateTimeField(auto_now_add=True)),
                ('org', models.ForeignKey(related_name='UO_org', related_query_name='UO_query_org', to='ac.Org')),
                ('org_role', models.ForeignKey(to='ac.OrgRole', default=3)),
                ('user', models.ForeignKey(related_name='UO_user', related_query_name='UO_query_user', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'tb_user_org',
            },
        ),
        migrations.CreateModel(
            name='UserProjectMap',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('create_date', models.DateTimeField(auto_now_add=True)),
                ('project', models.ForeignKey(to='ac.Project', related_name='UP_project')),
                ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='UP_user')),
            ],
            options={
                'db_table': 'tb_user_project_map',
            },
        ),
        migrations.CreateModel(
            name='UserRoleMap',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
                ('role', models.ForeignKey(related_name='UR_role', related_query_name='UR_query_role', to='ac.Role')),
                ('user', models.ForeignKey(related_name='UR_user', related_query_name='UR_query_user', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'tb_user_role_map',
            },
        ),
        migrations.AddField(
            model_name='pushtoken',
            name='user_project_map',
            field=models.ForeignKey(to='ac.UserProjectMap', related_name='PT'),
        ),
        migrations.AddField(
            model_name='project',
            name='status',
            field=models.ForeignKey(to='ac.Status'),
        ),
        migrations.AddField(
            model_name='org',
            name='org_level',
            field=models.ForeignKey(to='ac.OrgLevel', default=3),
        ),
        migrations.AddField(
            model_name='function',
            name='project',
            field=models.ForeignKey(to='ac.Project', related_name='F_project'),
        ),
        migrations.AddField(
            model_name='myuser',
            name='duty',
            field=models.ForeignKey(to='ac.Duty', null=True),
        ),
        migrations.AddField(
            model_name='myuser',
            name='groups',
            field=models.ManyToManyField(verbose_name='groups', related_name='user_set', related_query_name='user', blank=True, to='auth.Group', help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.'),
        ),
        migrations.AddField(
            model_name='myuser',
            name='site',
            field=models.ForeignKey(to='ac.Site'),
        ),
        migrations.AddField(
            model_name='myuser',
            name='status',
            field=models.ForeignKey(to='ac.Status', related_query_name='MU_query_status'),
        ),
        migrations.AddField(
            model_name='myuser',
            name='user_permissions',
            field=models.ManyToManyField(verbose_name='user permissions', related_name='user_set', related_query_name='user', blank=True, to='auth.Permission', help_text='Specific permissions for this user.'),
        ),
    ]
